<template>
  <div class="app-container">
  <!--  操作 模糊搜素  -->
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="商品延期" prop="instrument">
        <el-input
            v-model="queryParams.instrument"
            placeholder="请输入商品延期"
            clearable
            size="small"
            style="width: 240px"
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" size="small" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" size="small" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

  <!--  按钮  -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="warning"
            plain
            icon="Download"
            size="small"
            @click="handleExport"
            v-hasPermi="['marketdata:commodity:delInfo:exportPrice']"
        >当页导出
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="warning"
            plain
            icon="Download"
            size="small"
            @click="handleExportAll"
            v-hasPermi="['marketdata:commodity:delInfo:exportPrice']"
        >全量导出
        </el-button>
      </el-col>
    </el-row>

    <xTable ref="commodityRef" multiple="false" refId="commodityRef" v-loading="loading" :data="delaysList" @selection-change="handleSelectionChange">
      <template #columList>
      <el-table-column label="序号" type="index" width="40"></el-table-column>
      <el-table-column label="合约代码" align="left" :show-overflow-tooltip="true" prop="iCode"></el-table-column>
      <el-table-column label="合约名称" align="left" :show-overflow-tooltip="true" prop="name"></el-table-column>
      <el-table-column label="产品类型" align="center" :show-overflow-tooltip="true" prop="pType"></el-table-column>
      <el-table-column label="挂钩标的代码" align="left" prop="uICode" />
      <el-table-column label="报价单位" align="right" prop="unit"></el-table-column>
      <el-table-column label="面额计量单位" align="right" :show-overflow-tooltip="true" prop="exchangeUnit" :formatter="formartTableP4"></el-table-column>
      <el-table-column label="上市日期" align="center" :show-overflow-tooltip="true" prop="lDate"></el-table-column>
      </template>
    </xTable>

    <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />

  </div>
</template>

<script setup name="DelayInfo">
import {getCmdtdelInfoList} from '@/api/marketdata/commodity/commodity'

const {proxy} = getCurrentInstance();
const {M_TYPE} = proxy.useDict("M_TYPE");
const {A_TYPE} = proxy.useDict("A_TYPE");
const {CURRENCY} = proxy.useDict("CURRENCY");

const delaysList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const dateRange = ref([]);

const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 20,
    instrument: undefined
  }
});

const {queryParams} = toRefs(data);

/** 导出按钮操作 */
function handleExport() {
  proxy.download("marketdata/tcmdtController/exportdelInfo", {
    ...queryParams.value
  }, `商品延期${new Date().getTime()}.xlsx`);
}

/** 导出按钮操作 */
function handleExportAll() {
  proxy.download("marketdata/tcmdtController/exportdelInfo", Object.assign({
    ...queryParams.value
  }, {pageNum:'',pageSize: ''}), `商品延期${new Date().getTime()}.xlsx`);
}

/** 查询列表 */
function getList() {
  loading.value = true;
  getCmdtdelInfoList(queryParams.value).then(response => {
    delaysList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  queryParams.value.pageNum = 1;
  proxy.resetForm("queryRef");
  handleQuery();
}

getList()
</script>
